package com.blog.controller.adminarticle;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blog.controller.base.BaseServlet;
import com.blog.entity.AdminArticleEntity;
import com.blog.entity.AdminArticleQueryEntity;
import com.blog.service.frontpage.AdminArticleService;
import com.blog.utils.PageBean;

@WebServlet("/adminAllArtical")
public class AdminAllArticalServlet extends BaseServlet {

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		AdminArticleService service=AdminArticleService.getInstance();
		AdminArticleQueryEntity e=new AdminArticleQueryEntity();
		e.setPageSize(3);
		e.setStartindex(0);
		e.setStatus(0);
		List<AdminArticleEntity> articles=service.getNewAdminArticle(e);
		int totalRecord=(int) service.getTotalRecord(e).getTotalRecord();
		PageBean pageBean=new PageBean<AdminArticleEntity>(1, 3, totalRecord);
		pageBean.setList(articles);	
		req.setAttribute("pageBean",pageBean);
		forward("admin/allartical");
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
}

